<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>字符串形式的ref</title>
</head>
<body>
  <div id="app"></div>
  <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
  <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
  <!-- 生产环境中不建议使用 -->
  <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.7.2/prop-types.min.js"></script>

  <script type="text/babel">
    class Demo extends React.Component {
      handleClick = () => {
        const { input1 } = this.refs
        console.log(input1.value)
      }
      handleBlur = () => {
        const { input2 } = this.refs
        console.log(input2.value)
      }
      render() {
        return (
          <div>
            <input ref="input1" type="text" />
            <button onClick={this.handleClick}>点我提示左侧数据</button>
            <input ref='input2' onBlur={this.handleBlur} type="text" />
          </div>
        )
      }
    }
    ReactDOM.render(<Demo />, document.getElementById('app'))
  </script>
</body>
</html>